﻿<!DOCTYPE html>
<html>
<head>
    <title>农商互联开发平台</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <!--    <script src="/static/js/framework-ui.js"></script>-->
    <!--    <script src="/static/js/framework-clientdata.js"></script>-->

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>


    <!--    配置select多选相关-->
    <!--    <script src="/static/layui/dist/xm-select.js"></script>-->

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}


</head>
<body>
<style>
    .error{display: block;color:red}
    html, body {
        background-color: #FFF !important;
    }

    .modal-body {
        background-color: #fff;
        padding: 15px
    }

    .page-header {
        margin-top: 15px !important;
    }

    .geographic input {
        width: 100px !important;
        float: left;
        margin-right: 15px;
    }
</style>

<div class="modal-body">


    <div class="page-header">
        <h3>添加名单</h3>
    </div>

    <form class="form-horizontal layui-form">

        <div class="form-group">

            <div class="form-group">
                <label class="col-sm-1 control-label">*关联用户:</label>
                <div class="col-sm-4">
                    <div class="input-group ">
                        <input type="text" id="user" value="" class="form-control" disabled >
                        <input type="hidden" name="fans_id" value="" class="form-control" >
                        <span class="input-group-btn">
                        <button class="btn btn-default" id="user_btn" type="button">选择用户</button>
                    </span>
                    </div>
                </div>
            </div>




            <input type="hidden" name="content_id" value="{$id}">

        </div>


    </form>
</div>
<div class="add_button">

    <div class="form-group">
        <label class="col-sm-1 control-label"></label>
        <div class="col-sm-8">
            <a type="button" class="layui-btn layui-btn-primary" href="{:URL('community/content/registration')}?id={$id}">取消</a>
            <button type="button" class="layui-btn" id="newsave">保存</button>



            <!--            <button class="btn btn-primary btn-sm receive" data-id="1" data-title="提示" data-msg="总层数、每层户数保存成功后不能进行二次修改，是否确定保存" data-operation="newsave">保存-->
            <!--            </button>-->

        </div>
    </div>
</div>


<script>
    $(function() {
        $(this).find('.modal-dialog').css({
            'width': '1000px'
        });
    });
    var newModal = new yii.modal();

    var id = "{$id}";
    //关联用户
    $("#user_btn").click(function () {
        newModal.initialization({
            url: "{:URL('common/Common/userList')}",
            type: "post",
            data:{
                type:'detail',
                id:id
            }
        });
    });
    newModal.on("user_add",function(data){
        var id=$(newModal.getid()).find(".js_add").attr("data-id");
        var name=$(newModal.getid()).find(".js_add").attr("data-name");


        $('#user').val(name);
        $('input[name="fans_id"]').val(id);
    });


    $("#newsave").click(function () {
        var data = $("form").serializeArray();
        $.ajax({
            type: 'post',
            url: "{:URL('community/content/doRegistration')}",
            data: data,
            dataType: 'JSON',
            success: function (res) {
                if (res.code != 0) {
                    layer.alert(res.msg);
                } else {
                    window.location.href = "{:URL('community/content/registration')}?id="+id;
                }
            },
            error: function (res) {

            }
        });
    });




    layui.use(['form', 'layedit', 'tree', 'util','table'], function () {
        var form = layui.form
            , layer = layui.layer;
        var layedit = layui.layedit;
        var tree = layui.tree;
        var util = layui.util;

        layui.form.render('select');
        form.render();


    });
</script>

</body>
</html>